/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ntnu.superrss.models;

import com.sun.syndication.feed.synd.SyndFeed;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;

/**
 * POJO with Hibernate annotations.
 * @author Dyre <dyre.hult at gmail.com>
 */
@Entity
@Table(name = "CATEGORY")
public class Category implements Serializable {

    private Long id;
    private String title;
    private List<SyndFeed> feeds = new ArrayList<SyndFeed>();
    private User user;
//    private List<User> users = new ArrayList<User>();

    public Category() {
    }

    public Category(String title) {
        this.title = title;
    }

    @Id
    @GeneratedValue
    @Column(name = "ID")
    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
       this.id = id;
    }

    @Column(name = "TITLE")
    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @ManyToMany(
        targetEntity = SyndFeedImpl.class,
        cascade = {CascadeType.PERSIST, CascadeType.MERGE}
    )
    public List getFeeds() {
        return this.feeds;
    }

    public void setFeeds(List<SyndFeed> feeds) {
        this.feeds = feeds;
    }

    public void addFeeds(List<SyndFeed> feeds) {
        this.feeds.addAll(feeds);
    }

    public void addFeed(SyndFeed feed) {
        feeds.add(feed);
    }


    @ManyToOne(
        targetEntity = User.class,
        cascade = {CascadeType.PERSIST, CascadeType.MERGE}
    )
    public User getUser() {
        return this.user;
    }

    public void setUser(User users) {
        this.user = users;
    }

//    @ManyToMany(
//        targetEntity = User.class,
//        cascade = {CascadeType.PERSIST, CascadeType.MERGE}
//    )
//    public List getUsers() {
//        return this.users;
//    }

//    public void setUsers(List<User> users) {
//        this.users = users;
//    }

//    public void addUser(User user) {
//        this.users.add(user);
//    }
}